package routes

import (
	v1 "card/app/http/controllers/api/v1"
	"card/app/http/middlewares"
	"github.com/gin-gonic/gin"
)

func RegisterApiRouters(r *gin.Engine) {
	groupV1 := r.Group("/v1")
	{
		verify := new(v1.VerifyCodeController)
		groupV1.POST("/captcha", verify.ShowCaptcha)
		groupV1.POST("/send-email-code", verify.SendUsingEmail)
		register := new(v1.RegisterController)
		groupV1.POST("/register-by-email", register.RegisterByEmail)
		upload := new(v1.UploadController)
		groupV1.POST("/upload", upload.Upload)
		login := new(v1.LoginController)
		groupV1.POST("/login", login.Login, middlewares.LimitIP("5-M"))
		groupV1.POST("/refresh-token", login.RefreshToken, middlewares.LimitIP("5-M"))
		authMiddleWare := groupV1.Use(middlewares.AuthJWT())
		{
			profile := new(v1.ProfileController)
			authMiddleWare.POST("/profile", profile.Profile)
			authMiddleWare.POST("/update-user", profile.UpdateUserInfo)
		}
	}

}
